package com.ruoyi.map.controller;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

import com.ruoyi.map.domain.FhMapWater;
import com.ruoyi.map.domain.FhMapWeather;
import com.ruoyi.map.service.FhMapWeatherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Page;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;


import com.ruoyi.common.utils.poi.ExcelUtil;

import javax.servlet.http.HttpServletResponse;

/**
 * 城市天气管理Controller
 *
 * @author zcc
 * @date 2025-07-11
 */
@Api(description ="城市天气管理接口列表")
@RestController
@RequestMapping("/act/fhMapWeather")
public class FhMapWeatherController extends BaseController {
    @Autowired
    private FhMapWeatherService service;

    @ApiOperation("查询城市天气管理列表")
    @PreAuthorize("@ss.hasPermi('act:fhMapWeather:list')")
    @PostMapping("/list")
    public ResponseEntity<Page<FhMapWeather>> list(@RequestBody FhMapWeather query, Pageable page) {
        List<FhMapWeather> list = service.selectList(query, page);
        return ResponseEntity.ok(new PageImpl<>(list, page, ((com.github.pagehelper.Page)list).getTotal()));
    }


    @ApiOperation("获取城市天气管理详细信息")
    @PreAuthorize("@ss.hasPermi('act:fhMapWeather:query')")
    @GetMapping(value = "/{id}")
    public ResponseEntity<FhMapWeather> getInfo(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(service.selectById(id));
    }

    @ApiOperation("新增城市天气管理")
    @PreAuthorize("@ss.hasPermi('act:fhMapWeather:add')")
    @Log(title = "城市天气管理", businessType = BusinessType.INSERT)
    @PostMapping
    public ResponseEntity<Integer> add(@RequestBody FhMapWeather fhMapWeather) {
        return ResponseEntity.ok(service.insert(fhMapWeather));
    }

    @ApiOperation("修改城市天气管理")
    @PreAuthorize("@ss.hasPermi('act:fhMapWeather:edit')")
    @Log(title = "城市天气管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public ResponseEntity<Integer> edit(@RequestBody FhMapWeather fhMapWeather) {
        return ResponseEntity.ok(service.update(fhMapWeather));
    }

    @ApiOperation("删除城市天气管理")
    @PreAuthorize("@ss.hasPermi('act:fhMapWeather:remove')")
    @Log(title = "城市天气管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public ResponseEntity<Integer> remove(@PathVariable("ids") Long ids) {  // 修正参数注解
        return ResponseEntity.ok(service.deleteByIds(ids));
    }

}
